<template>
	<view class="coupon-block">
		<template v-if="lst.length>0">
			<block v-for='(item,index) in lst' :key="index">
				<item :itemData='item' :itemType='1' @itemClick='itemClick'></item>
			</block>
		</template>
		<template v-if="lst.length==0" @click="openMallCoupon">
			<view class="no-emty" style="font-size: 26rpx;color: #999;">暂无优惠券,
				<!-- <text style="color: #0055ff;" >去购买</text> -->
			</view>
		</template>
	</view>
</template>
<script>
	import item from '@/pages/coupon/components/item.vue'
	export default {
		components: {
			item
		},
		onShow() {
			this.init()
		},
		data() {
			return {
				lst: [],
			}
		},
		methods: {
			openMallCoupon(){
				uni.navigateTo({
					url:"/pages/mallCoupon/index/index"
				})
			},
			init() {
				this.$http('coupon.getMyCouponList',{
					token:this.$tools.getToken()
				}).then(res => {
					console.log('res', res)
					if (res.code == 200) {
						this.lst = res.data.list
					}
				})
			},
			itemClick(item) {
				
				console.log(item);
				uni.navigateTo({
					url:"/pages/shopDetail/shopDetail?goodsId="+item.commodity_id
				})
				
				// uni.switchTab({
				// 	url: '/pages/tabbar/index/index'
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.coupon-block {

		padding: 0 32rpx;
	}

	.no-emty {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 30rpx;
		font-size: 26rpx;
		color: #999
	}
</style>
